<template>
	<view style="width: 100%;height: 100%;padding: 20rpx;">
		<view
			style="width: 100%; display: flex;flex-direction: row;justify-content: space-between;height: 60rpx;position: fixed;margin-top: 10rpx;">
			<view style="font-size: 35rpx;font-weight: 700;color: #000;">用户评论</view>
		</view>
		<scroll-view scroll-y="true" style="width: 100%; height: auto;
		position: fixed;top: 100rpx;bottom: 120rpx; border-bottom: 2rpx solid #e5e5e5; ">
			<view style="width: 100%;display: flex;flex-direction: row;margin-top: 20rpx; height: 150rpx;
			border-bottom: 2rpx solid #e5e5e5;align-items: center;" v-for="(item,index) in pingLunList">
				<view>
						<image :src="'https://fcc.sdyilian.top/'+item.user.photo"
						style="width: 70rpx;width: 70rpx;border-radius: 35rpx;"></image>

				<!-- 	<image src="../../../static/pl.png" style="width: 70rpx;height: 70rpx;border-radius: 50rpx;">
					</image> -->
				</view>
				<view style="display:flex;flex-direction: column;margin-left: 10rpx;">
					<view style="font-size: 27rpx;font-weight: 700;">{{item.user.nickname}}</view>
					<view style="font-size: 29rpx;">{{item.create_time}}</view>
					<view style="font-size: 27rpx;">{{item.content}}</view>
				</view>
			</view>

		</scroll-view>

		<view style="width: 100%;position: fixed;bottom: 0;height: 100rpx;">
			<view
				style="width: 100%;display: flex;flex-direction: row;height: 100rpx;align-content: center;line-height: 100rpx;">
				<view
					style="height: 100rpx;line-height: 100rpx;display: flex;flex-direction: row;align-content: center;justify-content: center;">
					<input placeholder="写评论..." style="font-size: 30rpx;width: 500rpx; height: 50rpx;margin-top: 25rpx;
					margin-left: 15rpx;" v-model="text">
				</view>
				<view style="height: 100rpx;line-height: 100rpx;margin-left: 20rpx;">
					<button style="height: 70rpx;width: 120rpx;margin-top: 15rpx;line-height: 70rpx;color: #fff;background-color: #3c9cff;
					font-size: 30rpx;" @click="pingLun()">发送</button>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	var that;
	export default {
		data() {

			return {
				pingLunList: [],
				louPanId: -1,
				type: -1,
				text: ""
			}
		},
		onLoad(e) {
			that = this;
			that.louPanId = e.louPanId;
			that.type = e.type;
			that.getPingLunList();
		},
		methods: {
			pingLun() {
				if (that.text == "") {
					uni.showModal({
						title: '提示',
						content: '评论内容不能为空',
						showCancel: false,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
					return
				}
				var url = uni.api.API.comment_save;
				var parm = {
					id: that.louPanId,
					type: that.type,
					content: that.text
				}
				uni.api.HTTPREQUEST(url, "post", parm,
					that.pingLunSuss,
					that.pingLunFail, 1);
			},
			pingLunSuss(res) {
				uni.showToast({
					title: '评论成功'
				});
				that.getPingLunList();
				console.log(res);
			},
			pingLunFail(msg) {
				console.log(msg);
			},
			getPingLunList() {
				var url = uni.api.API.comment_list;
				var parm = {
					id: that.louPanId,
					type: that.type,
					page: 1
				}
				uni.api.HTTPREQUEST(url, "get", parm,
					that.getPingLunListSuss,
					that.getPingLunListFail, 1);
			},
			getPingLunListSuss(res) {
				that.pingLunList = res.data.data;
			
			},
			getPingLunListFail(msg) {
				console.log(msg)
			},
		}
	}
</script>

<style>

</style>